GenerativeComponents Help

The Switch Statement

Provides a way to select one path from among any number of alternates, depending on the value of an expression.

General Form

switch (expression)
{
	case value11:
	case value12:
	…
	case value1n:     statement11
		statement12
		…
		statement1n
			break;
	case value21:
	case value22:
	…
	case value2n:     statement21
		statement22
		…
		statement2n
			break;
	…
	case valuem1:
	case valuem2:
	…
	case valuemn:     statementm1
		statementm2
		…
		statementmn
			break;
	default:         
statementd1
		statementd2
		...
		statementdn
			break;
}

The result of the expression may be of any type that can be compared with each of the case values.

If any of the case values matches the result of the expression, the corresponding statements (and only those statements) are performed. Note that every sequence of statements must end with a break statement.

The default clause is optional, and takes effect only if none of the case values match the expression value. (In that case, if there is no default clause, then simply no statements are performed within the switch statement.)